home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / newapa / newapa.bst < prev    next >
Text File  |  1991-07-05  |  26KB  |  1,327 lines

  1. %$$$ newapa.bst $$$ --- June 13, 1991 (Version 2.0)
  2. %     - Version No. has not been kept, but let's say uh uh ... Version 2.0.
  3.  
  4. % REQUIRED is `newapa.sty' Version 2.0
  5. % Or alternatively required is a \LaTeX style file
  6. % or \TeX input file where
  7. % the following macros are defined:
  8. %  `\citestarts', `\citeends', `\betweenauthors'
  9. %
  10. % Also the \LaTeX style file or \TeX input file
  11. % should define macros line these:
  12. %
  13. %     \let\@internalcite\cite
  14. %     \def\fullcite{\def\citeauthoryear##1##2##3{##1, ##3}\@internalcite}
  15. %     \def\fullciteA{\def\citeauthoryear##1##2##3{##1}\@internalcite}
  16. %     \def\shortcite{\def\citeauthoryear##1##2##3{##2, ##3}\@internalcite}
  17. %     \def\shortciteA{\def\citeauthoryear##1##2##3{##2}\@internalcite}
  18. %     \def\citeyear{\def\citeauthoryear##1##2##3{##3}\@internalcite}
  19. %
  20.  
  21. % BibTeX `newapa' style file for BibTeX version 0.99c, LaTeX version 2.09
  22. % Place it in a file called newapa.bst in the BibTeX search path.  
  23. %(Placing it in the same directory as the LaTeX document should also work.)
  24. % Support for named citations is provided by named.sty
  25.  
  26. % This version was made by modifying the master file made by
  27. % Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU), and the 'named' BibTeX
  28. % style of Peter F. Patel-Schneider.
  29.  
  30. % Copyright (C) 1985, all rights reserved.
  31. % Modifications Copyright 1989, 1990, Stephen N. Spencer
  32. % Copying of this file is authorized only if either
  33. % (1) you make absolutely no changes to your copy, including name, or
  34. % (2) if you do make changes, you name it something other than
  35. % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  36. % This restriction helps ensure that all standard styles are identical.
  37.  
  38. % There are undoubtably bugs in this style.  If you make bug fixes,
  39. % improvements, etc.  please let me know.  My e-mail address is:
  40. %    spencer@heinlein.cgrg.ohio.state.edu
  41. %
  42.  
  43. %   Reference list ordering: alphabetical by author or whatever passes
  44. %    for author in the absence of one.
  45. %
  46. % This BibTeX style has support for abbreviated author lists and for
  47. %    year-only citations.  This is done by having the citations
  48. %    actually look like
  49. %
  50. % The LaTeX style has to have the following (or similar)
  51. %
  52.  
  53. ENTRY
  54.   { address
  55.     author
  56.     booktitle
  57.     chapter
  58.     edition
  59.     editor
  60.     howpublished
  61.     institution
  62.     journal
  63.     key
  64. %   month
  65.     note
  66.     number
  67.     organization
  68.     pages
  69.     publisher
  70.     school
  71.     series
  72.     title
  73.     type
  74.     volume
  75.     year
  76.   }
  77.   {}
  78.   { label extra.label sort.label }
  79.  
  80. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  81.  
  82. FUNCTION {init.state.consts}
  83. { #0 'before.all :=
  84.   #1 'mid.sentence :=
  85.   #2 'after.sentence :=
  86.   #3 'after.block :=
  87. }
  88.  
  89. STRINGS { s t u }
  90.  
  91. FUNCTION {output.nonnull}
  92. { 's :=
  93.   output.state mid.sentence =
  94.     { ", " * write$ }
  95.     { output.state after.block =
  96.     { add.period$ write$
  97.       newline$
  98.       "\newblock " write$
  99.     }
  100.     { output.state before.all =
  101.         'write$
  102.         { add.period$ " " * write$ }
  103.       if$
  104.     }
  105.       if$
  106.       mid.sentence 'output.state :=
  107.     }
  108.   if$
  109.   s
  110. }
  111.  
  112. FUNCTION {output.nonnull.colon}
  113. { 's :=
  114.   output.state mid.sentence =
  115.     { ": " * write$ }
  116.     { output.state after.block =
  117.     { add.period$ write$
  118.       newline$
  119.       "\newblock " write$
  120.     }
  121.     { output.state before.all =
  122.         'write$
  123.         { add.period$ " " * write$ }
  124.       if$
  125.     }
  126.       if$
  127.       mid.sentence 'output.state :=
  128.     }
  129.   if$
  130.   s
  131. }
  132.  
  133. FUNCTION {output}
  134. { duplicate$ empty$
  135.     'pop$
  136.     'output.nonnull
  137.   if$
  138. }
  139.  
  140. FUNCTION {output.check}
  141. { 't :=
  142.   duplicate$ empty$
  143.     { pop$ "empty " t * " in " * cite$ * warning$ }
  144.     'output.nonnull
  145.   if$
  146. }
  147.  
  148. FUNCTION {output.check.colon}
  149. { 't :=
  150.   duplicate$ empty$
  151.     { pop$ "empty " t * " in " * cite$ * warning$ }
  152.     'output.nonnull.colon
  153.   if$
  154. }
  155.  
  156. FUNCTION {output.year.check}
  157. { year empty$
  158.      { "empty year in " cite$ * warning$ }
  159.      { write$
  160.         " \citestarts" year * extra.label * "\citeends" *
  161.         mid.sentence 'output.state :=
  162.      }
  163.   if$
  164. }
  165.  
  166. FUNCTION {output.bibitem}
  167. { newline$
  168.  
  169.   "\bibitem[" write$
  170.   label write$
  171.   "]{" write$
  172.  
  173.   cite$ write$
  174.   "}" write$
  175.   newline$
  176.   ""
  177.   before.all 'output.state :=
  178. }
  179.  
  180. FUNCTION {fin.entry}
  181. { add.period$
  182.   write$
  183.   newline$
  184. }
  185.  
  186. FUNCTION {new.block}
  187. { output.state before.all =
  188.     'skip$
  189.     { after.block 'output.state := }
  190.   if$
  191. }
  192.  
  193. FUNCTION {new.sentence}
  194. { output.state after.block =
  195.     'skip$
  196.     { output.state before.all =
  197.     'skip$
  198.     { after.sentence 'output.state := }
  199.       if$
  200.     }
  201.   if$
  202. }
  203.  
  204. FUNCTION {not}
  205. {   { #0 }
  206.     { #1 }
  207.   if$
  208. }
  209.  
  210. FUNCTION {and}
  211. {   'skip$
  212.     { pop$ #0 }
  213.   if$
  214. }
  215.  
  216. FUNCTION {or}
  217. {   { pop$ #1 }
  218.     'skip$
  219.   if$
  220. }
  221.  
  222. FUNCTION {new.block.checka}
  223. { empty$
  224.     'skip$
  225.     'new.block
  226.   if$
  227. }
  228.  
  229. FUNCTION {new.block.checkb}
  230. { empty$
  231.   swap$ empty$
  232.   and
  233.     'skip$
  234.     'new.block
  235.   if$
  236. }
  237.  
  238. FUNCTION {new.sentence.checka}
  239. { empty$
  240.     'skip$
  241.     'new.sentence
  242.   if$
  243. }
  244.  
  245. FUNCTION {new.sentence.checkb}
  246. { empty$
  247.   swap$ empty$
  248.   and
  249.     'skip$
  250.     'new.sentence
  251.   if$
  252. }
  253.  
  254. FUNCTION {field.or.null}
  255. { duplicate$ empty$
  256.     { pop$ "" }
  257.     'skip$
  258.   if$
  259. }
  260.  
  261. FUNCTION {emphasize}
  262. { duplicate$ empty$
  263.     { pop$ "" }
  264.     { "{\em " swap$ * "}" * }
  265.   if$
  266. }
  267.  
  268. FUNCTION {emphasize.space}
  269. { duplicate$ empty$
  270.     { pop$ "" }
  271.     { "{\em " swap$ * "\/}" * }
  272.   if$
  273. }
  274.  
  275. INTEGERS { nameptr namesleft numnames }
  276.  
  277. FUNCTION {format.names}
  278. { 's :=
  279.   #1 'nameptr :=        % nameptr = 1;
  280.   s num.names$ 'numnames :=    % numnames = num.name$(s);
  281.   numnames 'namesleft :=
  282.     { namesleft #0 > }
  283.  
  284.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=
  285.  
  286.       nameptr #1 >
  287.         { namesleft #1 >
  288.               { ", " * t * }
  289.                { numnames #2 >
  290.                     { "," * }
  291.                     'skip$
  292.                   if$
  293.                   t "others" =
  294.                         { " et~al." * }
  295. %                        { " and " * t * }
  296.                         { " \betweenauthors{} " * t * }
  297.                       if$
  298.                 }
  299.                if$
  300.              }
  301.             't
  302.         if$
  303.         nameptr #1 + 'nameptr :=          % nameptr += 1;
  304.         namesleft #1 - 'namesleft :=      % namesleft =- 1;
  305.     }
  306.   while$
  307. }
  308.  
  309. FUNCTION {format.authors}
  310. { author empty$
  311.     { "" }
  312.     { author format.names }
  313.   if$
  314. }
  315.  
  316. FUNCTION {format.key}
  317. { empty$
  318.     { key field.or.null }
  319.     { "" }
  320.   if$
  321. }
  322.  
  323. FUNCTION {format.editors}
  324. { editor empty$
  325.     { "" }
  326.     { editor format.names
  327.       editor num.names$ #1 >
  328.     { " (Eds.)" * }
  329.     { " (Ed.)" * }
  330.       if$
  331.     }
  332.   if$
  333. }
  334.  
  335. FUNCTION {format.editors.dot}
  336. { editor empty$
  337.     { "" }
  338.     { editor format.names
  339.       editor num.names$ #1 >
  340.     { " (Eds.)." * }
  341.     { " (Ed.)." * }
  342.       if$
  343.     }
  344.   if$
  345. }
  346.  
  347. FUNCTION {format.title}
  348. { title empty$
  349.     { "" }
  350.     { title "t" change.case$ }
  351.   if$
  352. }
  353.  
  354. % Note that the APA style requres case changes
  355. % in article titles. The following does not
  356. % change cases. If you perfer it, uncomment the
  357. % following and comment out the above.
  358.  
  359. %FUNCTION {format.title}
  360. %{ title empty$
  361. %    { "" }
  362. %    { title }
  363. %  if$
  364. %}
  365.  
  366. FUNCTION {n.dashify}
  367. { 't :=
  368.   ""
  369.     { t empty$ not }
  370.     { t #1 #1 substring$ "-" =
  371.     { t #1 #2 substring$ "--" = not
  372.         { "--" *
  373.           t #2 global.max$ substring$ 't :=
  374.         }
  375.         {   { t #1 #1 substring$ "-" = }
  376.         { "-" *
  377.           t #2 global.max$ substring$ 't :=
  378.         }
  379.           while$
  380.         }
  381.       if$
  382.     }
  383.     { t #1 #1 substring$ *
  384.       t #2 global.max$ substring$ 't :=
  385.     }
  386.       if$
  387.     }
  388.   while$
  389. }
  390.  
  391. %FUNCTION {format.btitle}
  392. %{ title emphasize
  393. %}
  394.  
  395. FUNCTION {format.btitle}
  396. { edition empty$
  397.   { title emphasize }
  398.   { title empty$
  399.     { title emphasize }
  400.     { "{\em " title * "\/} (" * edition * " ed.)" * "." * }
  401.     if$
  402.   }
  403.   if$
  404. }
  405.  
  406. FUNCTION {format.emphasize.booktitle}
  407. { edition empty$
  408.   { booktitle emphasize }
  409.   { booktitle empty$
  410.     { booktitle emphasize }
  411.     { "{\em " booktitle * "\/} (" * edition * " ed.)" * "." * }
  412.     if$
  413.   }
  414.   if$
  415. }
  416.  
  417. FUNCTION {tie.or.space.connect}
  418. { duplicate$ text.length$ #3 <
  419.     { "~" }
  420.     { " " }
  421.   if$
  422.   swap$ * *
  423. }
  424.  
  425. FUNCTION {either.or.check}
  426. { empty$
  427.     'pop$
  428.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  429.   if$
  430. }
  431.  
  432. FUNCTION {format.bvolume}
  433. { volume empty$
  434.     { "" }
  435.     { "volume" volume tie.or.space.connect
  436.       series empty$
  437.     'skip$
  438.     { " of " * series emphasize * }
  439.       if$
  440.       "volume and number" number either.or.check
  441.     }
  442.   if$
  443. }
  444.  
  445. FUNCTION {format.number.series}
  446. { volume empty$
  447.     { number empty$
  448.     { series field.or.null }
  449.     { output.state mid.sentence =
  450.         { "number" }
  451.         { "Number" }
  452.       if$
  453.       number tie.or.space.connect
  454.       series empty$
  455.         { "there's a number but no series in " cite$ * warning$ }
  456.         { " in " * series * }
  457.       if$
  458.     }
  459.       if$
  460.     }
  461.     { "" }
  462.   if$
  463. }
  464.  
  465. FUNCTION {format.edition}
  466. { edition empty$
  467.     { "" }
  468.     { output.state mid.sentence =
  469.     { edition "l" change.case$ " edition" * }
  470.     { edition "t" change.case$ " edition" * }
  471.       if$
  472.     }
  473.   if$
  474. }
  475.  
  476. INTEGERS { multiresult }
  477.  
  478. FUNCTION {multi.page.check}
  479. { 't :=
  480.   #0 'multiresult :=
  481.     { multiresult not
  482.       t empty$ not
  483.       and
  484.     }
  485.     { t #1 #1 substring$
  486.       duplicate$ "-" =
  487.       swap$ duplicate$ "," =
  488.       swap$ "+" =
  489.       or or
  490.     { #1 'multiresult := }
  491.     { t #2 global.max$ substring$ 't := }
  492.       if$
  493.     }
  494.   while$
  495.   multiresult
  496. }
  497.  
  498. FUNCTION {format.pages}
  499. { pages empty$
  500.     { "" }
  501.     { pages multi.page.check
  502.     { "pages" pages n.dashify tie.or.space.connect }
  503.     { "page" pages tie.or.space.connect }
  504.       if$
  505.     }
  506.   if$
  507. }
  508.  
  509. %FUNCTION {format.vol.num.pages}
  510. %{ volume field.or.null
  511. %  number empty$
  512. %    'skip$
  513. %    { "(" number * ")" * *
  514. %      volume empty$
  515. %    { "there's a number but no volume in " cite$ * warning$ }
  516. %    'skip$
  517. %      if$
  518. %    }
  519. %  if$
  520. %  pages empty$
  521. %    'skip$
  522. %    { duplicate$ empty$
  523. %    { pop$ format.pages }
  524. %    { ":" * pages n.dashify * }
  525. %      if$
  526. %    }
  527. %  if$
  528. %}
  529.  
  530. % By Young
  531. FUNCTION {format.vol.num.pages}
  532. { number empty$
  533.     { volume empty$
  534.        'skip$
  535.        { "{\em " volume * "}" * }
  536.       if$
  537.     }
  538.     { volume emphasize.space
  539.       volume empty$
  540.        {"there's a number but no volume in " cite$ * warning$ }
  541.        { "(" number * ")" * * }
  542.       if$
  543.     }
  544.   if$
  545.   pages empty$
  546.     'skip$
  547.     { duplicate$ empty$
  548.       { pop$ format.pages }
  549.       { ", " * pages n.dashify * }
  550.       if$
  551.     }
  552.   if$
  553. }
  554.  
  555. FUNCTION {format.chapter.pages}
  556. { chapter empty$
  557.     'format.pages
  558.     { type empty$
  559.     { "chapter" }
  560.     { type "l" change.case$ }
  561.       if$
  562.       chapter tie.or.space.connect
  563.       pages empty$
  564.     'skip$
  565.     { ", " * format.pages * }
  566.       if$
  567.     }
  568.   if$
  569. }
  570.  
  571. FUNCTION {format.in.ed.booktitle}
  572. { booktitle empty$
  573.     { "" }
  574.     { editor empty$
  575.     { "In " format.emphasize.booktitle * }
  576.     { "In " format.editors * ", " * format.emphasize.booktitle * }
  577.       if$
  578.     }
  579.   if$
  580. }
  581.  
  582. FUNCTION {format.thesis.type}
  583. { type empty$
  584.     'skip$
  585.     { pop$
  586.       type "t" change.case$
  587.     }
  588.   if$
  589. }
  590.  
  591. FUNCTION {format.tr.number}
  592. { type empty$
  593.     { "Technical Report" }
  594.     'type
  595.   if$
  596.   number empty$
  597.     { "t" change.case$ }
  598.     { number tie.or.space.connect }
  599.   if$
  600. }
  601.  
  602. FUNCTION {format.article.crossref}
  603. { "In"
  604.   "\cite{" * crossref * "}" *
  605. }
  606.  
  607. FUNCTION {format.crossref.editor}
  608. { editor #1 "{vv~}{ll}" format.name$
  609.   editor num.names$ duplicate$
  610.   #2 >
  611.     { pop$ " et~al." * }
  612.     { #2 <
  613.     'skip$
  614.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  615.         { " et~al." * }
  616.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  617.       if$
  618.     }
  619.       if$
  620.     }
  621.   if$
  622. }
  623.  
  624. FUNCTION {format.book.crossref}
  625. { volume empty$
  626.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  627.       "In "
  628.     }
  629.     { "Volume" volume tie.or.space.connect
  630.       " of " *
  631.     }
  632.   if$
  633.   editor empty$
  634.   editor field.or.null author field.or.null =
  635.   or
  636.     { key empty$
  637.     { series empty$
  638.         { "need editor, key, or series for " cite$ * " to crossref " *
  639.           crossref * warning$
  640.           "" *
  641.         }
  642.         { "{\em " * series * "\/}" * }
  643.       if$
  644.     }
  645.     { key * }
  646.       if$
  647.     }
  648.     { format.crossref.editor * }
  649.   if$
  650.   " \cite{" * crossref * "}" *
  651. }
  652.  
  653. FUNCTION {format.incoll.inproc.crossref}
  654. { "In"
  655.   " \cite{" * crossref * "}" *
  656. }
  657.  
  658. FUNCTION {article}
  659. { output.bibitem
  660.   format.authors "author" output.check
  661.   author format.key output          % added
  662.   output.year.check                 % added
  663.   new.block
  664.   format.title "title" output.check
  665.   new.block
  666.   crossref missing$
  667.     { journal emphasize "journal" output.check
  668.       format.vol.num.pages output
  669.     }
  670.     { format.article.crossref output.nonnull
  671.       format.pages output
  672.     }
  673.   if$
  674.   new.block
  675.   note output
  676.   fin.entry
  677. }
  678.  
  679. FUNCTION {book}
  680. { output.bibitem
  681.   author empty$
  682.     { format.editors.dot "author and editor" output.check }
  683.     { format.authors output.nonnull
  684.       crossref missing$
  685.     { "author and editor" editor either.or.check }
  686.     'skip$
  687.       if$
  688.     }
  689.   if$
  690.   output.year.check       % added
  691.   new.block
  692.   format.btitle "title" output.check
  693.   crossref missing$
  694.     { format.bvolume output
  695.       new.block
  696.       format.number.series output
  697.       new.sentence
  698.       address output
  699.       publisher "publisher" output.check.colon
  700.     }
  701.     { new.block
  702.       format.book.crossref output.nonnull
  703.     }
  704.   if$
  705. %  format.edition output
  706.   new.block
  707.   note output
  708.   fin.entry
  709. }
  710.  
  711. FUNCTION {booklet}
  712. { output.bibitem
  713.   format.authors output
  714.   author format.key output          % added
  715.   output.year.check                 % added
  716.   new.block
  717.   format.title "title" output.check
  718.   new.block
  719.   howpublished output
  720.   address output
  721.   new.block
  722.   note output
  723.   fin.entry
  724. }
  725.  
  726. FUNCTION {inbook}
  727. { output.bibitem
  728.   author empty$
  729.     { format.editors.dot "author and editor" output.check }
  730.     { format.authors output.nonnull
  731.       crossref missing$
  732.     { "author and editor" editor either.or.check }
  733.     'skip$
  734.       if$
  735.     }
  736.   if$
  737.   output.year.check                 % added
  738.   new.block
  739.   format.btitle "title" output.check
  740.   crossref missing$
  741.     { format.bvolume output
  742.       format.chapter.pages "chapter and pages" output.check
  743.       new.block
  744.       format.number.series output
  745.       new.sentence
  746.       address output
  747.       publisher "publisher" output.check.colon
  748.     }
  749.     { format.chapter.pages "chapter and pages" output.check
  750.       new.block
  751.       format.book.crossref output.nonnull
  752.     }
  753.   if$
  754. %  format.edition output
  755.   new.block
  756.   note output
  757.   fin.entry
  758. }
  759.  
  760. FUNCTION {incollection}
  761. { output.bibitem
  762.   format.authors "author" output.check
  763.   author format.key output       % added
  764.   output.year.check              % added
  765.   new.block
  766.   format.title "title" output.check
  767.   new.block
  768.   crossref missing$
  769.     { format.in.ed.booktitle "booktitle" output.check
  770.       format.bvolume output
  771.       format.number.series output
  772.       format.chapter.pages output
  773.       new.sentence
  774.       address output
  775.       publisher "publisher" output.check.colon
  776. %      format.edition output
  777.     }
  778.     { format.incoll.inproc.crossref output.nonnull
  779.       format.chapter.pages output
  780.     }
  781.   if$
  782.   new.block
  783.   note output
  784.   fin.entry
  785. }
  786.  
  787. FUNCTION {inproceedings}
  788. { output.bibitem
  789.   format.authors "author" output.check
  790.   author format.key output            % added
  791.   output.year.check                   % added
  792.   new.block
  793.   format.title "title" output.check
  794.   new.block
  795.   crossref missing$
  796.     { format.in.ed.booktitle "booktitle" output.check
  797.       format.bvolume output
  798.       format.number.series output
  799.       format.pages output
  800.       address output
  801.         new.sentence
  802.        organization output
  803.        publisher output
  804.      }
  805.     { format.incoll.inproc.crossref output.nonnull
  806.       format.pages output
  807.     }
  808.   if$
  809.   new.block
  810.   note output
  811.   fin.entry
  812. }
  813.  
  814. FUNCTION {conference} { inproceedings }
  815.  
  816. FUNCTION {manual}
  817. { output.bibitem
  818.   format.authors output
  819.   author format.key output          % added
  820.   output.year.check                 % added
  821.   new.block
  822.   format.btitle "title" output.check
  823.   organization address new.block.checkb
  824.   organization output
  825.   address output
  826. %  format.edition output
  827.   new.block
  828.   note output
  829.   fin.entry
  830. }
  831.  
  832. FUNCTION {mastersthesis}
  833. { output.bibitem
  834.   format.authors "author" output.check
  835.   author format.key output          % added
  836.   output.year.check                 % added
  837.   new.block
  838.   format.title "title" output.check
  839.   new.block
  840.   "Master's thesis" format.thesis.type output.nonnull
  841.   school "school" output.check
  842.   address output
  843.   new.block
  844.   note output
  845.   fin.entry
  846. }
  847.  
  848. FUNCTION {misc}
  849. { output.bibitem
  850.   format.authors output
  851.   author format.key output            % added
  852.   output.year.check                   % added
  853.   title howpublished new.block.checkb
  854.   format.title output
  855.   new.block
  856.   howpublished output
  857.   new.block
  858.   note output
  859.   fin.entry
  860. }
  861.  
  862. FUNCTION {phdthesis}
  863. { output.bibitem
  864.   format.authors "author" output.check
  865.   author format.key output            % added
  866.   output.year.check                   % added
  867.   new.block
  868.   format.btitle "title" output.check
  869.   new.block
  870.   "PhD thesis" format.thesis.type output.nonnull
  871.   school "school" output.check
  872.   address output
  873.   new.block
  874.   note output
  875.   fin.entry
  876. }
  877.  
  878. FUNCTION {proceedings}
  879. { output.bibitem
  880.   editor empty$
  881.     { organization output }
  882.     { format.editors.dot output.nonnull }
  883.   if$
  884.   author format.key output             % added
  885.   output.year.check                    % added
  886.   new.block
  887.   format.btitle "title" output.check
  888.   format.bvolume output
  889.   format.number.series output
  890.   address output
  891.   new.sentence
  892.   organization output
  893.   publisher output
  894.   new.block
  895.   note output
  896.   fin.entry
  897. }
  898.  
  899. FUNCTION {techreport}
  900. { output.bibitem
  901.   format.authors "author" output.check
  902.   author format.key output             % added
  903.   output.year.check                    % added
  904.   new.block
  905.   format.title "title" output.check
  906.   new.block
  907.   format.tr.number output.nonnull
  908.   institution "institution" output.check
  909.   address output
  910.   new.block
  911.   note output
  912.   fin.entry
  913. }
  914.  
  915. FUNCTION {unpublished}
  916. { output.bibitem
  917.   format.authors "author" output.check
  918.   author format.key output              % added
  919.   output.year.check                      % added
  920.   new.block
  921.   format.title "title" output.check
  922.   new.block
  923.   note "note" output.check
  924.   fin.entry
  925. }
  926.  
  927. FUNCTION {default.type} { misc }
  928.  
  929. MACRO {jan} {"January"}
  930.  
  931. MACRO {feb} {"February"}
  932.  
  933. MACRO {mar} {"March"}
  934.  
  935. MACRO {apr} {"April"}
  936.  
  937. MACRO {may} {"May"}
  938.  
  939. MACRO {jun} {"June"}
  940.  
  941. MACRO {jul} {"July"}
  942.  
  943. MACRO {aug} {"August"}
  944.  
  945. MACRO {sep} {"September"}
  946.  
  947. MACRO {oct} {"October"}
  948.  
  949. MACRO {nov} {"November"}
  950.  
  951. MACRO {dec} {"December"}
  952.  
  953. MACRO {acmcs} {"ACM Computing Surveys"}
  954.  
  955. MACRO {acta} {"Acta Informatica"}
  956.  
  957. MACRO {ai} {"Artificial Intelligence"}
  958.  
  959. MACRO {cacm} {"Communications of the ACM"}
  960.  
  961. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  962.  
  963. MACRO {ibmsj} {"IBM Systems Journal"}
  964.  
  965. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  966.  
  967. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  968.  
  969. MACRO {ieeetcad}
  970.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  971.  
  972. MACRO {ipl} {"Information Processing Letters"}
  973.  
  974. MACRO {jacm} {"Journal of the ACM"}
  975.  
  976. MACRO {jcss} {"Journal of Computer and System Sciences"}
  977.  
  978. MACRO {scp} {"Science of Computer Programming"}
  979.  
  980. MACRO {sicomp} {"SIAM Journal on Computing"}
  981.  
  982. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  983.  
  984. MACRO {tods} {"ACM Transactions on Database Systems"}
  985.  
  986. MACRO {tog} {"ACM Transactions on Graphics"}
  987.  
  988. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  989.  
  990. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  991.  
  992. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  993.  
  994. MACRO {tcs} {"Theoretical Computer Science"}
  995.  
  996. READ
  997.  
  998. FUNCTION {sortify}
  999. { purify$
  1000.   "l" change.case$
  1001. }
  1002.  
  1003. INTEGERS { len }
  1004.  
  1005. FUNCTION {chop.word}
  1006. { 's :=
  1007.   'len :=
  1008.   s #1 len substring$ =
  1009.     { s len #1 + global.max$ substring$ }
  1010.     's
  1011.   if$
  1012. }
  1013.  
  1014. INTEGERS { fullptr numfull fullsleft }
  1015.  
  1016. STRINGS { u1 u2 }
  1017.  
  1018. FUNCTION {my.full.label}
  1019. % Initialize 'u1','u2','s'.
  1020.   "" 'u1 :=                                       
  1021.   "" 'u2 :=                     
  1022.   's :=                      
  1023.  
  1024. % Initialize 'fullptr','numfull','fullsleft'.
  1025.   #1 'fullptr :=                         
  1026.   s num.names$ 'numfull :=   
  1027.   numfull 'fullsleft :=          
  1028.  
  1029. % enter the while loop which generates the first-citation information.
  1030. % while we have names left, 
  1031. %     format the next name
  1032. %   if this is the next-to-last name, tack the ampersand on the end
  1033. %   else if this isn't the last name, tack the comma on the end.
  1034. %   concatenate the next name onto the first-citation string.
  1035. %   update the counters.
  1036.  
  1037.   { fullsleft #0 > }
  1038.   { s fullptr "{vv~}{ll}" format.name$ 'u1 :=  
  1039.      fullsleft #2 =
  1040.        { u1 " \betweenauthors{} " * 'u1 := }
  1041.       { fullsleft #2 > 
  1042.            { u1 ", " * 'u1 := }
  1043.            'skip$
  1044.          if$
  1045.         }
  1046.     if$
  1047.      u2 u1 * 'u2 :=
  1048.      fullptr #1 + 'fullptr :=         
  1049.      fullsleft #1 - 'fullsleft :=  
  1050.   }
  1051.   while$
  1052.  
  1053. % push 'u2' onto the stack -- our first-citation information.
  1054.   u2        
  1055. }
  1056.  
  1057. FUNCTION {format.lab.names}
  1058. { 's :=                             
  1059.   s #1 "{vv~}{ll}" format.name$        
  1060.   s num.names$ duplicate$
  1061.   #2 >                                
  1062.      { pop$ " et~al." * }            
  1063.      { #2 <
  1064.           'skip$
  1065.           { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1066.                 { "et~al. " * }
  1067. %               { " and " * s #2 "{vv~}{ll}" format.name$ * }
  1068.                 { " \betweenauthors{} " * s #2 "{vv~}{ll}" format.name$ * }
  1069.              if$
  1070.             }
  1071.        if$
  1072.      }
  1073.   if$
  1074. }
  1075.  
  1076. FUNCTION {author.key.label}
  1077. { author empty$
  1078.     { key empty$
  1079.           { cite$ #1 #3 substring$ }
  1080.          'key
  1081.       if$
  1082.     }
  1083.     { author format.lab.names }
  1084.   if$
  1085. }
  1086.  
  1087. FUNCTION {editor.key.label}
  1088. { editor empty$
  1089.     { key empty$
  1090.           { cite$ #1 #3 substring$ }
  1091.           'key
  1092.         if$
  1093.      }
  1094.      { editor format.lab.names }
  1095.   if$
  1096. }
  1097.  
  1098. FUNCTION {author.editor.key.label}
  1099. { author empty$
  1100.     { editor empty$
  1101.           { key empty$
  1102.                { cite$ #1 #3 substring$ }
  1103.              'key
  1104.            if$
  1105.          }
  1106.           { editor format.lab.names }
  1107.       if$
  1108.     }
  1109.     { author format.lab.names }
  1110.   if$
  1111. }
  1112.  
  1113. FUNCTION {calc.label}
  1114. { type$ "book" =
  1115.   type$ "inbook" =
  1116.   or
  1117.     'author.editor.key.label
  1118.     { type$ "proceedings" =
  1119.           'editor.key.label
  1120.           'author.key.label
  1121.         if$
  1122.     }
  1123.   if$
  1124.   duplicate$    
  1125.  
  1126.   author my.full.label  % generate the first-citation information.
  1127.  
  1128.   "\protect\citeauthoryear{" swap$ * "}{" * swap$ * "}{" *
  1129.   year field.or.null purify$ #-1 #4 substring$ *  
  1130.   'label :=
  1131.   year field.or.null purify$ #-1 #4 substring$ *
  1132.   sortify 'sort.label :=
  1133. }
  1134.  
  1135. FUNCTION {sort.format.names}
  1136. { 's :=
  1137.   #1 'nameptr :=
  1138.   ""
  1139.   s num.names$ 'numnames :=
  1140.   numnames 'namesleft :=
  1141.     { namesleft #0 > }
  1142.     { nameptr #1 >
  1143.           { "   " * }
  1144.          'skip$
  1145.       if$
  1146.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't :=
  1147.       nameptr numnames = t "others" = and
  1148.           { "et al" * }
  1149.           { t sortify * }
  1150.       if$
  1151.       nameptr #1 + 'nameptr :=
  1152.       namesleft #1 - 'namesleft :=
  1153.     }
  1154.   while$
  1155. }
  1156.  
  1157. FUNCTION {sort.format.title}
  1158. { 't :=
  1159.   "A " #2
  1160.     "An " #3
  1161.       "The " #4 t chop.word
  1162.     chop.word
  1163.   chop.word
  1164.   sortify
  1165.   #1 global.max$ substring$
  1166. }
  1167.  
  1168. FUNCTION {author.sort}
  1169. { author empty$
  1170.     { key empty$
  1171.           { "to sort, need author or key in " cite$ * warning$
  1172.               ""
  1173.          }
  1174.          { key sortify }
  1175.       if$
  1176.     }
  1177.     { author sort.format.names }
  1178.   if$
  1179. }
  1180.  
  1181. FUNCTION {editor.sort}
  1182. { editor empty$
  1183.     { key empty$
  1184.          { "to sort, need editor or key in " cite$ * warning$
  1185.            ""
  1186.          }
  1187.          { key sortify }
  1188.       if$
  1189.     }
  1190.     { editor sort.format.names }
  1191.   if$
  1192. }
  1193.  
  1194. FUNCTION {author.editor.sort}
  1195. { author empty$
  1196.     { editor empty$
  1197.          { key empty$
  1198.              { "to sort, need author, editor, or key in " cite$ * warning$
  1199.                ""
  1200.              }
  1201.              { key sortify }
  1202.            if$
  1203.          }
  1204.          { editor sort.format.names }
  1205.       if$
  1206.    }
  1207.    { author sort.format.names }
  1208.   if$
  1209. }
  1210.  
  1211. FUNCTION {presort}
  1212. { calc.label
  1213.   label sortify
  1214.   "    "
  1215.   *
  1216.   type$ "book" =
  1217.   type$ "inbook" =
  1218.   or
  1219.     'author.editor.sort
  1220.     { type$ "proceedings" =
  1221.           'editor.sort
  1222.           'author.sort
  1223.       if$
  1224.     }
  1225.   if$
  1226.   #1 entry.max$ substring$        % added for newapa
  1227.   'sort.label :=                  % added for newapa
  1228.   sort.label                      % added for newapa
  1229.   *
  1230.   "    "
  1231.   *
  1232.   title field.or.null
  1233.   sort.format.title
  1234.   *
  1235.   #1 entry.max$ substring$
  1236.   'sort.key$ :=
  1237. }
  1238.  
  1239. ITERATE {presort}
  1240.  
  1241. SORT             % by label, sort.label, title --- for final label calculation
  1242.  
  1243. STRINGS { last.label next.extra }
  1244.  
  1245. INTEGERS { last.extra.num }
  1246.  
  1247. FUNCTION {initialize.extra.label.stuff}
  1248. { #0 int.to.chr$ 'last.label :=
  1249.   "" 'next.extra :=
  1250.   #0 'last.extra.num :=
  1251. }
  1252.  
  1253. FUNCTION {forward.pass}
  1254. { last.label label =
  1255.      { last.extra.num #1 + 'last.extra.num :=
  1256.        last.extra.num int.to.chr$ 'extra.label :=
  1257.      }
  1258.      { "a" chr.to.int$ 'last.extra.num :=
  1259.        "" 'extra.label :=
  1260.        label 'last.label :=
  1261.     }
  1262.   if$
  1263. }
  1264.  
  1265. FUNCTION {reverse.pass}
  1266. { next.extra "b" =
  1267.     { "a" 'extra.label := }
  1268.      'skip$
  1269.   if$
  1270.   label extra.label * "}" * 'label :=   
  1271.   extra.label 'next.extra :=
  1272. }
  1273.  
  1274. EXECUTE {initialize.extra.label.stuff}
  1275.  
  1276. ITERATE {forward.pass}
  1277.  
  1278. REVERSE {reverse.pass}
  1279.  
  1280. FUNCTION {bib.sort.order}
  1281. { sort.label
  1282.   "    "
  1283.   *
  1284.   year field.or.null sortify
  1285.   *
  1286.   "    "
  1287.   *
  1288.   title field.or.null
  1289.   sort.format.title
  1290.   *
  1291.   #1 entry.max$ substring$
  1292.   'sort.key$ :=
  1293. }
  1294.  
  1295. ITERATE {bib.sort.order}
  1296.  
  1297. SORT             % by sort.label, year, title --- giving final bib. order.
  1298.  
  1299. FUNCTION {begin.bib}
  1300.  
  1301. { preamble$ empty$
  1302.     'skip$
  1303.     { preamble$ write$ newline$ }
  1304.   if$
  1305.   "\begin{thebibliography}{}" write$ newline$
  1306. %  "\addcontentsline{toc}{section}{Reference}" write$ newline$
  1307. %  "\baselineskip=14pt" write$ newline$
  1308. %  "\parskip=2pt" write$ newline$
  1309. }
  1310.  
  1311.  
  1312. EXECUTE {begin.bib}
  1313.  
  1314. EXECUTE {init.state.consts}
  1315.  
  1316. ITERATE {call.type$}
  1317.  
  1318. FUNCTION {end.bib}
  1319. { newline$
  1320.   "\end{thebibliography}" write$ newline$
  1321. }
  1322.  
  1323. EXECUTE {end.bib}
  1324.  
  1325.